package yamen.bdwm.board;


import yamen.bdwm.BoardFragment;
import yamen.bdwm.MainActivity;
import yamen.bdwm.R;
import yamen.bdwm.data.interfaces.onListRefreshedListener;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ListFragment extends Fragment implements onListRefreshedListener{
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState)
	{
		View v= inflater.inflate(R.layout.list, container,false);
			
		String xxx[]=new String[]{"a","b","c"};
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getActivity(),android.R.layout.simple_list_item_1,xxx);
		((ListView)v.findViewById(R.id.listView1)).setAdapter(adapter);
		((ListView)v.findViewById(R.id.listView1)).setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Fragment f=((MainActivity)ListFragment.this.getActivity()).getCurrentFragment();
				if(f instanceof BoardFragment)
				{
					((BoardFragment) f).showThread(""+position,"");
				}
			}
		});
		return v;

	}

	public void onRefreshed(int numberOfRefreshed) {
		// TODO Auto-generated method stub
		
	}

	public void onError(int i) {
		// TODO Auto-generated method stub
		
	}

	

}
